﻿@using Models
@model List<Tag>

@{
    var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    FormsAuthenticationTicket auth = null;
    if (cookie != null)
    {
        auth = FormsAuthentication.Decrypt(cookie.Value);

        ViewBag.auth = auth;
    }

    ViewBag.Title = "Tags";
}
<div style="float: left; height: 70px"><a href="/admin/index" ><img src="/Content/images/back.png" /></a></div>
<div style="margin-left: 15px; text-align: center; width: 100px"><a href="/admin/AddTag" ><img src="/content/images/tags_add.png" width="48" height="48" alt="Add tag" /><br />Add tag</a></div>

<h2>Tags</h2>
 @Html.Partial("_openDialog")
 
 @if (Model == null)
 {
     <span><h1>No tags</h1></span>
 }
 else
 {
     <table id="table_admin">
    <tr>
        
        <td style="width: 90px;">
            @Html.ActionLink("Id", "Tags", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "id" }, null)
        </td>
        
     
        <td style="width: 80px;">
            @Html.ActionLink("Name", "Tags", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "name" }, null)
        </td>    
        <td>
            Action button
        </td>
    </tr>
    
    @for (int i = ViewBag.pager.StartIndex - 1; i < ViewBag.pager.EndIndex; i++)
    {
        <tr>
            <td>
                @Model[i].Id
            </td>
            <th>
                @Model[i].Name
            </th>
            <td>
                <a href="/Admin/UpdateTag/@Model[i].Id"><img src="/content/images/Refresh.png" alt="Update" /></a>

                    
                    @if (auth.UserData == "1")
                    {
                        <a href="/admin/deleteTag/@Model[i].Id" onmousedown="return openDialog(@Model[i].Id,'/Admin/DeleteTag')"><img src="/content/images/Delete.png" alt="Delete" /></a>
                    }
              
            </td>
        </tr>
    }
</table>
 }
